@use "variables";
@use "helpers";

* {
    box-sizing: border-box;
}

html {
    background-color: variables.$bg-primary !important;

    body {
        margin: 0;
        background-color: variables.$bg-primary !important;
    }

    .iu {
        font-family: system-ui;
        @include helpers.main-layout;
        display: flex;
        flex-direction: column;
        
        .overlay {
            color: variables.$clr-white;
        }

        .app-header {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            height: 4rem;
            background-color: variables.$bg-secondary;
            z-index: 1;
            @extend .flex;

            &-content {
                padding: 0 variables.$size-medium;
                justify-content: space-between;
                @include helpers.main-layout;
                @extend .flex;
                @extend .align-center;
            }

            .logo {
                display: flex;
                flex-direction: row;
                gap: variables.$size-small;
                align-items: center;
                justify-content: center;
                font-size: 1rem;
                letter-spacing: 2px;
                cursor: pointer;

                .logo-text {
                    display: flex;
                    flex-direction: column;
                    justify-content: center;
                    align-items: center;
                    font-weight: 500;
                }
            }

            .search-bar {
                color: variables.$clr-white;
                border-radius: variables.$border-radius;
                padding: variables.$size-small;
                font-weight: bold;
                font-family: inherit;
                background-color: transparent;
                border: 1px solid variables.$clr-border;
            }
        }

        .app-sidebar {
            position: sticky;
            top: 0;
            overflow: auto;
            height: 100vh;
            min-width: 300px;
            border-inline-end: 1px solid #333;
            @extend .flex;
            @extend .column;
            @extend .p-medium;
            @extend .fs-large;
            @extend .with-app-header;
        }


        label {
            cursor: pointer;
        }

        input[type='checkbox'] {
            height: 1.1rem;
            width: 1.1rem;
        }

        a {
            color: inherit;
            text-decoration-color: transparent;
            transition: text-decoration-color 0.1s;
            cursor: pointer;

            &:hover {
                text-decoration-color: inherit;
            }
        }

        button {
            border: 1px solid variables.$clr-black;
            cursor: pointer;
            background-color: variables.$bg-secondary;
            border-radius: variables.$border-radius;
            color: variables.$clr-white;
            @extend .p-clear;

            &.copy-list {
                font-weight: 300;
                color: variables.$clr-white;
                background-color: variables.$clr-black;
                padding: 5px;
                border-radius: 5px;
                @extend .fs-medium;
            }

            &.run-scan {
                background-color: transparent;
                position: absolute;
                left: 50%;
                top: 50%;
                transform: translate(-50%, -50%);
                font-size: 2em;
                color: variables.$clr-white;
                border: 1px solid variables.$clr-white;
                height: 160px;
                width: 160px;
                border-radius: 50%;
            }

            &.run-scan:hover {
                background-color: variables.$bg-secondary;
            }

            &.unfollow {
                margin-bottom: variables.$size-large;
                background-color: variables.$clr-red !important;
                @extend .badge;
                @extend .fs-large;
                @extend .clr-inherit;
            }
        }

        .progressbar {
            width: 100%;
            height: 8px;
            position: absolute;
            // Fix: Added explicit positioning to prevent white gap at the end
            // Without left: 0 and top: 0, the progress bar doesn't fully align
            left: 0;
            top: 0;
        }

        .results-container,
        .unfollow-log-container {
            @extend .grow;
            @extend .with-app-header;
        }

        .results-container {
            .alphabet-character {
                border-bottom: 1px solid variables.$bg-secondary;
                @extend .m-medium;
                @extend .p-medium;
                @extend .fs-xlarge;
            }

            .result-item {
                border-radius: 3px;
                cursor: pointer;
                @extend .flex;
                @extend .align-center;
                @extend .p-medium;

                .avatar-container {
                    @extend .pos-relative;

                    &:hover {
                        & .avatar {
                            filter: brightness(0.25) blur(3px);
                        }

                        & .avatar-icon-overlay-container {
                            display: inline-block;
                        }
                    }

                    .avatar {
                        width: 75px;
                        border-radius: 50%;
                    }

                    .avatar-icon-overlay-container {
                        position: absolute;
                        top: 50%;
                        left: 50%;
                        transform: translate(-50%, -50%);
                        @extend .d-none;
                    }
                }

                .verified-badge {
                    background-color: #49adf4;
                    border-radius: 50%;
                    padding: 0.2rem 0.3rem;
                    font-size: 0.45em;
                    height: fit-content;
                    transform: translateY(-15px);
                }

                .private-indicator {
                    border: 2px solid #51bb42;
                    border-radius: 25px;
                    color: #51bb42;
                    font-weight: 500;
                    @extend .p-small;
                }
            }
        }

        .unfollow-log-container {
            @extend .p-medium;
        }

        .tabs-container {
            @extend .flex;
            @extend .p-large;

            .tab {
                color: variables.$clr-gray;
                border-radius: 8px;
                cursor: pointer;
                @extend .grow;
                @extend .fs-xlarge;
                @extend .t-center;
                @extend .p-small;

                &-active {
                    color: inherit;
                    background-color: variables.$bg-secondary;
                }
            }
        }

        .badge {
            background: variables.$bg-secondary;
            border-radius: 15px;
            @extend .p-medium;
        }
    }
}

.toast {
    position: fixed;
    display: flex;
    opacity: 1;
    justify-content: space-between;
    align-items: start;
    width: 100%;
    max-width: 360px;
    padding: 0.8em;
    gap: 0.5em;
    bottom: variables.$size-medium;
    right: variables.$size-medium;
    color: variables.$clr-black;
    background-color: variables.$clr-white;
    font-size: 1.25em;
    border-radius: 6px;
    z-index: 2;
    box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.2);
    animation: slide-out 0.5s ease-in-out;

    >.toast {
        &__message {
            display: flex;
            margin: 0;
        }

        &__close-button {
            background: none;
            border: none;
            color: inherit;
            cursor: pointer;
            font-size: 1em;
        }
    }

    .show {
        animation: slide-in 0.5s ease-in-out;
        display: flex;
        opacity: 1;
    }

    &.success {
        background-color: variables.$clr-green;
        color: variables.$clr-white;
    }

    &.error {
        background-color: variables.$clr-red;
        color: variables.$clr-white;
    }

    &.info {
        background-color: #2196f3;
        color: variables.$clr-white;
    }

    &.warning {
        background-color: #fdd835;
        color: variables.$clr-black;
    }
}

.controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding: 0;
    @extend .fs-large;
    @extend .p-medium;

    .button-control {
        background-color: variables.$bg-secondary;
        border-radius: variables.$border-radius;
        padding: 0.5rem 1rem;
        color: variables.$clr-white;
        cursor: pointer;
    }

    .button-pause {
        width: 100%;
    }
}